
#ifndef SOUND_H
#define SOUND_H

#if defined(_WIN32)
#include <al.h>
#include <alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif

namespace al
{

/**
 * Represents a sound loaded from disk.
 */
class Sound
{
public:
    Sound();

    virtual ~Sound();

    /**
     * Loads a WAV sound file and fills this sound's buffer with it.
     * If buffer is not empty it will be released first.
     * @param path
     * @return true in success
     */
    bool LoadWAV(const char* path);

    /**
     * Loads an OGG sound file and fills this sound's buffer with it.
     * If buffer is not empty it will be released first.
     * @param path
     * @return true in success
     */
    bool LoadOGG(const char* path);

    /**
     * Release the internal buffer.
     * @return 
     */
    bool Release();

    /**
     * Returns the id given to the internal buffer by OpenAL.
     * @return 
     */
    ALuint GetBufferId();

private:

    /**
     * Sets the buffer id.
     * @param buffer
     * @return 
     */
    bool SetData(ALuint buffer);

    /**
     * The id of the buffer.
     */
    ALuint bufferId;
};

};
#endif
